/// Author: Samle
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../controllers/edit_words_controller.dart';
/// 特殊自定义组件
import '../../../../util/EasyInput.dart';

class EditWordsView extends GetView<EditWordsController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          leading: IconButton(
              icon: const Icon(Icons.arrow_back_ios),
              onPressed: Get.back
          ),
          elevation: 0,
          backgroundColor: Colors.black87,
          title: const Text("编辑词卡"),
          centerTitle: true,
          actions: <Widget>[
            IconButton(
              icon: const Icon(
                Icons.save,
                color: Colors.white,
              ),
              onPressed: (){controller.saveData();},
            ),
          ]
      ),
      body: Container(
        padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
        child: ListView(
          children: [
            EasyInput(
              value: controller.name.text,
              keyboardType: "text",
              title: "单词",
              hintText: "请输入单词：",
              values: (value) {
                controller.name.text = value;
              },
            ),
            EasyInput(
              value: controller.trans.text,
              keyboardType: "text",
              title: "翻译",
              hintText: "请输入翻译：",
              values: (value) {
                controller.trans.text = value;
              },
            ),
            EasyInput(
              value: controller.ukphone.text,
              keyboardType: "text",
              title: "英音音标",
              hintText: "请输入英音音标：",
              values: (value) {
                controller.ukphone.text = value;
              },
            ),
            EasyInput(
              value: controller.ukspeech.text,
              keyboardType: "text",
              title: "英音发音参数",
              hintText: "请输入英音发音参数：",
              values: (value) {
                controller.ukspeech.text = value;
              },
            ),
            EasyInput(
              value: controller.usphone.text,
              keyboardType: "text",
              title: "美音音标",
              hintText: "请输入美音音标：",
              values: (value) {
                controller.usphone.text = value;
              },
            ),
            EasyInput(
              value: controller.usspeech.text,
              keyboardType: "text",
              title: "美音发音参数",
              hintText: "请输入美音发音参数：",
              values: (value) {
                controller.usspeech.text = value;
              },
            ),
            EasyInput(
              value: controller.syno.text,
              keyboardType: "text",
              title: "近义词",
              hintText: "请输入近义词：",
              values: (value) {
                controller.syno.text = value;
              },
            ),
            EasyInput(
              value: controller.relWord.text,
              keyboardType: "text",
              title: "同根词",
              hintText: "请输入同根词：",
              values: (value) {
                controller.relWord.text = value;
              },
            ),
            EasyInput(
              value: controller.sentence.text,
              keyboardType: "text",
              title: "例句",
              hintText: "请输入例句：",
              values: (value) {
                controller.sentence.text = value;
              },
            ),
            EasyInput(
              value: controller.phrase.text,
              keyboardType: "text",
              title: "短语",
              hintText: "请输入短语：",
              values: (value) {
                controller.phrase.text = value;
              },
            ),
            EasyInput(
              value: controller.exam.text,
              keyboardType: "text",
              title: "相关测试",
              hintText: "请输入相关测试：",
              values: (value) {
                controller.exam.text = value;
              },
            ),
            EasyInput(
              value: controller.belong.text,
              keyboardType: "text",
              title: "所属词典",
              hintText: "请输入所属词典：",
              values: (value) {
                controller.belong.text = value;
              },
            ),
            EasyInput(
              value: controller.checkTimes.text,
              keyboardType: "number",
              title: "记忆次数",
              hintText: "请输入记忆次数：",
              values: (value) {
                controller.checkTimes.text = value;
              },
            ),
            EasyInput(
              value: controller.errorTimes.text,
              keyboardType: "number",
              title: "错误次数",
              hintText: "请输入错误次数：",
              values: (value) {
                controller.errorTimes.text = value;
              },
            ),
            EasyInput(
              value: controller.helpText.text,
              keyboardType: "text",
              title: "助记词",
              hintText: "请输入助记词：",
              values: (value) {
                controller.helpText.text = value;
              },
            ),
            EasyInput(
              value: controller.soundText.text,
              keyboardType: "text",
              title: "助音词",
              hintText: "请输入助音词：",
              values: (value) {
                controller.soundText.text = value;
              },
            ),
          ],
        ),
      ),
    );
  }
}
